package com.jiangjun.fetch.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.jiangjun.fetch.mongo.MongoDBSupport;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;

public class ReleaseWeiboAction extends DispatchAction {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		String id = request.getParameter("id");
		MongoDBSupport mongoDBSupport = MongoDBSupport.getInstance();
		BasicDBObject param = new BasicDBObject();
		param.put("id", id);
		DBObject dbObject = mongoDBSupport.queryOneByParam(
				MongoDBSupport._WEIBO, param, null);
		dbObject.put("isEnable", "1");
		mongoDBSupport.findAndModifyCollection(MongoDBSupport._WEIBO, param, dbObject);
		return mapping.findForward("success");
	}

}
